package com.fmy.jurisdiction.config.spring.web.jackson;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.Timestamp;
import java.time.LocalDateTime;


/**
 * <p>
 * 自定义 ObjectMapper 转换
 * <p>
 *
 * @ClassName CustomObjectWrapper
 * @Aulthor Mr.fmy
 * @Version 1.0
 * @Date 2019/8/28 18:25
 **/
@Component
public class CustObjectMapper {

    @Autowired
    public CustObjectMapper(ObjectMapper objectMapper) {
        SimpleModule module = new SimpleModule();
        module.addSerializer(Timestamp.class, new TimestampSerializer());
        module.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer());
        objectMapper.registerModule(module);
    }
}
